import smtplib
from email.mime.text import MIMEText


def sned_qq_email(data: dict):
    tar = "1514866421@qq.com"
    # 邮件构建
    title = "%s这个网站发生变化" % data.get("url")
    # 发送方
    sender = "1514866421@qq.com"
    # 内容
    content = "%s,链接:%s" % (data.get("content"), data.get("ret_url"))
    # 授权码 这里是
    password = "faeujnaoqxfbfhdb"

    message = MIMEText(content, "plain", "utf-8")

    message["Subject"] = title
    message["To"] = tar
    message["From"] = sender

    try:

        smtp = smtplib.SMTP_SSL("smtp.qq.com", 465)
        smtp.login(sender, password)
        smtp.sendmail(sender, tar, message.as_string())
        smtp.quit()
        smtp.close()
    except Exception as e:
        print("error--", e)
